package com.vision.sales.sv.serv;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.vision.core.sv.util.CollectionUtils;

public class SalesReportParams extends PrintReportParams {
	
	protected static final DateFormat yyyyMMdd = new SimpleDateFormat("yyyyMMdd");
	
	String title;
	List<Long> companyIds;
	List<Long> customerIds;
	
	public SalesReportParams(HttpServletRequest req) {
		super(req);
		
		title = req.getParameter("title");
		if (title != null)
		{
			title = title.trim();
		}
		
		String sCompanyIds = req.getParameter("companies");
		if (sCompanyIds != null)
			companyIds = CollectionUtils.longsFromString(sCompanyIds, ',');
		
		String sCustomerIds = req.getParameter("customers");
		if (sCustomerIds != null)
			customerIds = CollectionUtils.longsFromString(sCustomerIds, ',');
	}
	
	public void setDefaultTitle(String defaultTitle)
	{
		if (title == null || title.isEmpty())
		{
			title = defaultTitle;
		}
	}
}